//
//  UIBarButtonItem+Category.swift
//  swift_wobo
//
//  Created by yuxin on 2018/11/15.
//  Copyright © 2018 wuxiantianli. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    class func creatBarButtonItem(imageName:String, target: AnyObject?, action: Selector) -> UIBarButtonItem {
        let btn = UIButton()
        btn.frame = CGRect(x: 0, y: 0, width: 30, height: 30);
        btn.setImage(UIImage(named: imageName), for: .normal)
        btn.setImage(UIImage(named: imageName+"_highlighted"), for: .highlighted)
        btn.addTarget(target, action: action, for: .touchUpInside)
        return UIBarButtonItem(customView: btn)
    }
    class func creatBarButtonItem(title: String, target: AnyObject?, action: Selector) -> UIBarButtonItem {
        let btn = UIButton()
        btn.frame = CGRect(x: 0, y: 0, width: 60, height: 44);
        btn.setTitle(title, for: .normal)
        btn.addTarget(target, action: action, for: .touchUpInside)
        return UIBarButtonItem(customView: btn)
    }
}
